// 同时发送异步代码的次数
let ajaxTimes = 0;
export const request = (params) => {

	var token = wx.getStorageSync("token") || '';

	let urls = params.url
	
	// 定义公共的url
	const baseUrl = "https://www.xiaouhegongyi.cn/";
	return new Promise((resolve, reject) => {
		wx.request({
			...params,
			header: {
				'TOKEN': `${token}`
			},
			url: baseUrl + urls,
			success: (result) => {
				resolve(result.data);
			},
			fail: (err) => {
				reject(err);
			},
			complete: () => {
				ajaxTimes--;
				if (ajaxTimes === 0) {
					//  关闭正在等待的图标
					wx.hideLoading();
				}
			}
		});
	})
}